package com.example.administrator.mobilesafe.utils;

import android.accounts.AccountManager;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;

import java.util.List;

/**
 * Created by Administrator on 2015/9/2.
 */
public class CheckService {
    public static boolean isServiceRunning(Context context,String serviceName){
        ActivityManager activityManager =(ActivityManager)  context.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningServiceInfo> infos = activityManager.getRunningServices(100);
        for (ActivityManager.RunningServiceInfo info:infos){
            String name = info.service.getClassName();
            if(name.equals(serviceName))
                return true;
        }
        return false;
    }
}
